package com.galaxy.service.service.system.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.galaxy.service.dto.system.log.QueryLogDto;
import com.galaxy.service.entity.system.SysLog;
import com.galaxy.service.mapper.system.SysLogMapper;
import com.galaxy.service.service.system.SysLogService;
import java.util.List;
import org.springframework.stereotype.Service;

/**
 * 系统日志接口实现类
 * @author caijinbang
 * @date 2018/10/27 19:14
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper,SysLog> implements SysLogService {

  /**
   * 日志列表
   * @param queryLogDto 日志查询过滤条件
   * @return
   */
  @Override
  public Page<SysLog> list(QueryLogDto queryLogDto) {
    EntityWrapper<SysLog> wrapper = new EntityWrapper<>();
    wrapper.orderBy("create_date",queryLogDto.getAsc());
    return this.selectPage(new Page<>(queryLogDto.getPage(),queryLogDto.getPageSize()),wrapper);
  }

  /**
   * 删除日志
   * @param idList 日志id集合
   */
  @Override
  public void remove(List<String> idList) {
    try {
      this.deleteBatchIds(idList);
    }catch (Exception e){
      throw new RuntimeException("批量删除日志失败",e);
    }
  }
}
